﻿using System;
using System.Windows;
using Blackbird.Studio.Control;
using Blackbird.Studio.View;
using Blackbird.Studio.ViewModel;

namespace Blackbird.Studio
{
    /// <summary>
    /// Interaction logic for App.xaml
    /// </summary>
    public partial class App
    {
        protected override void OnStartup(StartupEventArgs e) {
            
            base.OnStartup(e);

            var window = new MainWindow();
            //var window = new ImageGridDesignWindow();
            // Create the ViewModel to which 
            // the main window binds.
            var viewModel = new MainWindowViewModel();
            //var viewModel = ImageGridDesignerViewModel.Instance;

            // When the ViewModel asks to be closed, 
            // close the window.
            EventHandler handler = null;
            EventHandler handlerCopy = handler;
            handler = delegate {
                viewModel.RequestClose -= handlerCopy;
                window.Close();
            };
            viewModel.RequestClose += handler;

            // Allow all controls in the window to 
            // bind to the ViewModel by setting the 
            // DataContext, which propagates down 
            // the element tree.
            window.DataContext = viewModel;

            window.Show();
        }
    }
}
